package top.hzy520.shopcart.service;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import top.hzy520.common.constants.Constants;
import top.hzy520.shopcart.feign.ValuationServiceClient;
import top.hzy520.user.entity.UserElement;
import top.hzy520.shopcart.dto.ProductSkuInputDto;
import top.hzy520.shopcart.dto.ProductSkuOutputDto;
import top.hzy520.shopcart.dto.ShopCartOutputDto;
import top.hzy520.shopcart.entity.ProductSku;
import top.hzy520.shopcart.feign.GoodsServiceClient;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.UnsupportedEncodingException;
import java.math.BigDecimal;
import java.net.URLDecoder;
import java.net.URLEncoder;
import java.util.*;

/**
 * @Author: HouZeYu
 * @Description:
 * @Date: Created in 20:50 2018/6/12
 */
@Service
public class ShopCartServiceImpl implements ShopCartService {
      /***   商品状态 ***/
    private static final Integer SKU_NOTCHOOSE_STATUS = 1; //商品未被选择

    private static final Integer SKU_CHOOSE_STATUS = 0; //商品被选择
    @Autowired
    private RedisTemplate redisTemplate;
    @Autowired
    private GoodsServiceClient goodsServiceClient;
    @Autowired
    private ValuationServiceClient valuationGoodsPrice;
    /**
    *@Author: HouZeYu
    *@Description: 添加购物车  判断该用户是否登录如果登录则直接存入redis中 如果未登录 则获取用户设备ip存入cookie中
    *@Date: 9:03 2018/6/13
    */
    @Override
    public ShopCartOutputDto addShopCart(UserElement userElement, String ip, List<ProductSkuInputDto> skuInputDtoList, HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException {
        if (userElement==null){
        //用户未登录先查询该设备是否为空
      Cookie[] cookies=request.getCookies();
      for (int i=0;i<cookies.length;i++){
          if (cookies[i].getName().equals(ip)){
              //获取该设备对应cookie中的购物车
            String cookieCart=URLDecoder.decode(cookies[i].getValue(),"UTF-8");
            //把cookie里嘛存储的string类型转成shopcart类型
             ShopCartOutputDto shopCartOutputDto= JSON.parseObject(cookieCart,  new TypeReference<ShopCartOutputDto>() {} );
             skuInputDtoList.stream().forEach(param->{
                 ProductSkuOutputDto  skuOutputDto=null;
                 //查询购物车里是否已经添加了该商品
                 for (int j=0;j<shopCartOutputDto.getSkuOutputDtoList().size();j++){
                        if (param.getSkuId().equals(shopCartOutputDto.getSkuOutputDtoList().get(j).getId())){
                          skuOutputDto=shopCartOutputDto.getSkuOutputDtoList().get(j);
                        }
                 }
                 //如果存在在购物车里面则直接增加购物车里面改商品的数量和总金钱
                 if (skuOutputDto!=null){
                         if (skuOutputDto.getChooseSign().equals(SKU_NOTCHOOSE_STATUS)){
                             skuOutputDto.setQuantity(param.getQuantity());
                             skuOutputDto.setTotalPrice(skuOutputDto.getActivityPrice().multiply(new BigDecimal(param.getQuantity())));
                         }else { // 计算商品花费单价
                        shopCartOutputDto.setTotalChooseSkuQuantity(shopCartOutputDto.getTotalChooseSkuQuantity()+(param.getQuantity()-skuOutputDto.getQuantity()));
                        shopCartOutputDto.setShopCartTotalPrice(shopCartOutputDto.getShopCartTotalPrice().add(skuOutputDto.getActivityPrice().multiply(new BigDecimal(param.getQuantity()-skuOutputDto.getQuantity()))));
                        shopCartOutputDto.setTotalFavourablePrice(shopCartOutputDto.getTotalFavourablePrice().add((skuOutputDto.getSkuPrice().subtract(skuOutputDto.getActivityPrice())).multiply(new BigDecimal(param.getQuantity()-skuOutputDto.getQuantity()))));
                        skuOutputDto.setQuantity(param.getQuantity());
                        skuOutputDto.setTotalPrice(skuOutputDto.getActivityPrice().multiply(new BigDecimal(param.getQuantity())));}
                 }else {
                     //如果不存在则调用商品服务查询商品信息并添加商品去购物车并修改商品总金钱
                     skuOutputDto=new ProductSkuOutputDto();
                     Set<Long> longs=new HashSet<>();
                     longs.add(param.getSkuId());
                     List<ProductSku> skuList= goodsServiceClient.selectGoodsBySkuId(longs).getData();
                      BigDecimal price=valuationGoodsPrice.valuationGoodsPrice(skuList.get(0));
                     skuOutputDto.setId(param.getSkuId());
                     skuOutputDto.setImgUrl(skuList.get(0).getImgUrl());
                     skuOutputDto.setQuantity(param.getQuantity());
                     skuOutputDto.setSkuPrice(skuList.get(0).getSkuPrice());
                     skuOutputDto.setActivityPrice(price);
                     skuOutputDto.setChooseSign(SKU_CHOOSE_STATUS);
                     skuOutputDto.setTotalPrice(price.multiply(new BigDecimal(param.getQuantity())));
                     shopCartOutputDto.setTotalFavourablePrice(shopCartOutputDto.getTotalFavourablePrice().add((skuList.get(0).getSkuPrice().subtract(price)).multiply(new BigDecimal(param.getQuantity()))));
                     shopCartOutputDto.setTotalChooseSkuQuantity(shopCartOutputDto.getTotalChooseSkuQuantity()+param.getQuantity());
                     shopCartOutputDto.getSkuOutputDtoList().add(skuOutputDto);
                     shopCartOutputDto.setShopCartTotalPrice(shopCartOutputDto.getShopCartTotalPrice().add(price.multiply(new BigDecimal(param.getQuantity()))));
                 }
             });
              //并存入cookie中
              String cart=JSON.toJSONString(shopCartOutputDto);
              Cookie cookie=new Cookie(ip,URLEncoder.encode(cart,"UTF-8"));
              response.addCookie(cookie);
             return shopCartOutputDto;
          }
      }
      //设备为空则为该设备创建购物车
      String cookieShopCart=JSON.toJSONString(addNewShopCart(skuInputDtoList));
      Cookie cookie=new Cookie(ip,URLEncoder.encode(cookieShopCart,"UTF-8"));
      response.addCookie(cookie);
      return addNewShopCart(skuInputDtoList);
  }else {
      //判断 该用户 登录前 是否 已经添加了 购物车 如果 添加 则 清除 该购物车cookie
      Cookie[] cookies=request.getCookies();
      for(int i=0;i<cookies.length;i++){
          if (cookies[i].getName().equals(ip)){
              cookies[i].setValue(null);
              cookies[i].setMaxAge(0);
              response.addCookie(cookies[i]);
          }
      }
      //用户已经登录查询该用户redis中的购物车是否为空
   Object object=redisTemplate.opsForHash().entries(Constants.SHOPCART_USER_KEY+":"+userElement.getUuid().toString());
   //如果为空则查询商品属性创建购物车
       if (((Map) object).size()==0){
         ShopCartOutputDto cartOutputDto=addNewShopCart(skuInputDtoList);
           redisTemplate.opsForHash().putAll(Constants.SHOPCART_USER_KEY+":"+userElement.getUuid().toString(),cartOutputDto.toMap());
           return cartOutputDto;
           //如果购物车不为空则从redis中取出购物车并查询商品是否存在如果存在则修改商品数量和商品总价
       }else {
           Map<String,Object> map= (Map<String, Object>) object;
             ShopCartOutputDto shopCartInRedis= ShopCartOutputDto.fromMap(map);
             //查询商品是否已经添加在购物车了
           skuInputDtoList.stream().forEach(param->{
               ProductSkuOutputDto skuOutputDto=null;
                  for (int i=0;i<shopCartInRedis.getSkuOutputDtoList().size();i++){
                      if (param.getSkuId().equals(shopCartInRedis.getSkuOutputDtoList().get(i).getId())){
                            skuOutputDto=shopCartInRedis.getSkuOutputDtoList().get(i);
                      }
                  }
               //没有这个商品则添加商品去购物车并改变价格和数量
             if (skuOutputDto==null){
                    //拼装添加的商品参数
                        ProductSkuOutputDto skuOutputInRedis=new ProductSkuOutputDto();
                       Set<Long> longs=new HashSet<>();
                       longs.add(param.getSkuId());
                       List<ProductSku> skuList= goodsServiceClient.selectGoodsBySkuId(longs).getData();
                     BigDecimal price= valuationGoodsPrice.valuationGoodsPrice(skuList.get(0));
                        skuOutputInRedis.setId(param.getSkuId());
                        skuOutputInRedis.setQuantity(param.getQuantity());
                        skuOutputInRedis.setChooseSign(SKU_CHOOSE_STATUS);
                        skuOutputInRedis.setImgUrl(skuList.get(0).getImgUrl());
                        skuOutputInRedis.setTotalPrice(price.multiply(new BigDecimal(param.getQuantity())));
                        skuOutputInRedis.setSkuPrice(skuList.get(0).getSkuPrice());
                        skuOutputInRedis.setActivityPrice(price);
                        shopCartInRedis.setTotalFavourablePrice(shopCartInRedis.getTotalFavourablePrice().add((skuList.get(0).getSkuPrice().subtract(price)).multiply(new BigDecimal(param.getQuantity()))));
                        shopCartInRedis.setTotalChooseSkuQuantity(shopCartInRedis.getTotalChooseSkuQuantity()+param.getQuantity());
                        shopCartInRedis.getSkuOutputDtoList().add(skuOutputInRedis);
                        shopCartInRedis.setShopCartTotalPrice(shopCartInRedis.getShopCartTotalPrice().add(price));
                 }else {
                 if (skuOutputDto.getChooseSign().equals(SKU_NOTCHOOSE_STATUS)){
                     skuOutputDto.setQuantity(param.getQuantity());
                     skuOutputDto.setTotalPrice(skuOutputDto.getActivityPrice().multiply(new BigDecimal(param.getQuantity())));
                 }else {
                     //如果有这个商品则改变商品的数量和价格
                     shopCartInRedis.setTotalChooseSkuQuantity(shopCartInRedis.getTotalChooseSkuQuantity() + (param.getQuantity() - skuOutputDto.getQuantity()));
                     shopCartInRedis.setTotalFavourablePrice(shopCartInRedis.getTotalFavourablePrice().add((skuOutputDto.getSkuPrice().subtract(skuOutputDto.getActivityPrice())).multiply(new BigDecimal(param.getQuantity() - skuOutputDto.getQuantity()))));
                     shopCartInRedis.setShopCartTotalPrice(shopCartInRedis.getShopCartTotalPrice().add(skuOutputDto.getActivityPrice().multiply(new BigDecimal(param.getQuantity() - skuOutputDto.getQuantity()))));
                     skuOutputDto.setQuantity(param.getQuantity());
                     skuOutputDto.setTotalPrice(skuOutputDto.getActivityPrice().multiply(new BigDecimal(param.getQuantity())));
                 }}
           });
           redisTemplate.opsForHash().putAll(Constants.SHOPCART_USER_KEY+":"+userElement.getUuid().toString(),shopCartInRedis.toMap());
           return shopCartInRedis;
       }
  }
    }
      /**
      *@Author: HouZeYu
      *@Description: 展示购物车列表  判断用户是否登录如果没有登录则查看cookie里面的购物车
      *@Date: 15:38 2018/6/19
      */
    @Override
    public ShopCartOutputDto shopCartList(String ip, UserElement currentUser, HttpServletRequest request) throws UnsupportedEncodingException {
         //判断用户是否登录
        if (currentUser==null){
            //用户未登录则查看cookie里面ip对用的购物车
            Cookie[] cookies=request.getCookies();
            for (int i=0;i<cookies.length;i++){
                if (cookies[i].getName().equals(ip)){
                    String cookieCart=URLDecoder.decode(cookies[i].getValue(),"UTF-8");
                    //把cookie里嘛存储的string类型转成shopcart类型
                    ShopCartOutputDto shopCartOutputDto= JSON.parseObject(cookieCart,  new TypeReference<ShopCartOutputDto>() {} );
                    return shopCartOutputDto;
                }
            }

        }else {
              //用户登录则从redis中取出该用户的购物车
         Object object=redisTemplate.opsForHash().entries(Constants.SHOPCART_USER_KEY+":"+currentUser.getUuid().toString());
                   Map<String,Object> map= (Map<String, Object>) object;
                   //将map转化为shopcart类型
                    ShopCartOutputDto shopCartOutputDto= ShopCartOutputDto.fromMap(map);
                    return shopCartOutputDto;
        }
        return null;
    }
   /**
   *@Author: HouZeYu
   *@Description: 删除购物车里面的商品
   *@Date: 16:06 2018/6/19
   */
    @Override
    public ShopCartOutputDto delShopCart(List<ProductSkuInputDto> skuInputDtoList, String ip, UserElement currentUser, HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException {
        if (currentUser==null){
            //用户未登录则查看cookie里面ip对用的购物车
            Cookie[] cookies=request.getCookies();
            for (int i=0;i<cookies.length;i++){
                if (cookies[i].getName().equals(ip)){
                    String cookieCart=URLDecoder.decode(cookies[i].getValue(),"UTF-8");
                    //把cookie里嘛存储的string类型转成shopcart类型
                    ShopCartOutputDto shopCartOutputDto= JSON.parseObject(cookieCart,  new TypeReference<ShopCartOutputDto>() {} );
                    //查找购物车中的商品将其删除
                    skuInputDtoList.stream().forEach(param->{
                      ProductSkuOutputDto skuOutputDto=shopCartOutputDto.getSkuOutputDtoList().stream().filter(sku->sku.getId().equals(param.getSkuId())).findFirst().get();
                      shopCartOutputDto.getSkuOutputDtoList().remove(skuOutputDto);
                      if (skuOutputDto.getChooseSign().equals(SKU_CHOOSE_STATUS)){
                          shopCartOutputDto.setTotalFavourablePrice(shopCartOutputDto.getTotalFavourablePrice().subtract((skuOutputDto.getSkuPrice().subtract(skuOutputDto.getActivityPrice())).multiply(new BigDecimal(skuOutputDto.getQuantity()))));
                          shopCartOutputDto.setTotalChooseSkuQuantity(shopCartOutputDto.getTotalChooseSkuQuantity() - skuOutputDto.getQuantity());
                          shopCartOutputDto.setShopCartTotalPrice(shopCartOutputDto.getShopCartTotalPrice().subtract(skuOutputDto.getActivityPrice().multiply(new BigDecimal(skuOutputDto.getQuantity()))));
                      }
                    });
                    if (shopCartOutputDto.getSkuOutputDtoList().size()==0){
                           //如果购物车变为空则不存入cookie中
                        cookies[i].setValue(null);
                        cookies[i].setMaxAge(0);
                        response.addCookie(cookies[i]);
                        return null;
                    }
                    //并存入cookie中
                    String cart=JSON.toJSONString(shopCartOutputDto);
                    Cookie cookie=new Cookie(ip,URLEncoder.encode(cart,"UTF-8"));
                    response.addCookie(cookie);
                    return shopCartOutputDto;
                }
            }
        }else {
            //用户登录则从redis中取出该用户的购物车
            Object object=redisTemplate.opsForHash().entries(Constants.SHOPCART_USER_KEY+":"+currentUser.getUuid().toString());
            Map<String,Object> map= (Map<String, Object>) object;
            //将map转化为shopcart类型
            ShopCartOutputDto shopCartInRedis= ShopCartOutputDto.fromMap(map);
            //查找购物车中的商品将其删除
            skuInputDtoList.stream().forEach(param->{
                ProductSkuOutputDto skuOutputDto=shopCartInRedis.getSkuOutputDtoList().stream().filter(sku->sku.getId().equals(param.getSkuId())).findFirst().get();
                shopCartInRedis.getSkuOutputDtoList().remove(skuOutputDto);
                if (skuOutputDto.getChooseSign().equals(SKU_CHOOSE_STATUS)) {
                    shopCartInRedis.setTotalFavourablePrice(shopCartInRedis.getTotalFavourablePrice().subtract((skuOutputDto.getSkuPrice().subtract(skuOutputDto.getActivityPrice())).multiply(new BigDecimal(skuOutputDto.getQuantity()))));
                    shopCartInRedis.setTotalChooseSkuQuantity(shopCartInRedis.getTotalChooseSkuQuantity() - skuOutputDto.getQuantity());
                    shopCartInRedis.setShopCartTotalPrice(shopCartInRedis.getShopCartTotalPrice().subtract(skuOutputDto.getActivityPrice().multiply(new BigDecimal(skuOutputDto.getQuantity()))));
                }
            });
            //存入redis删除后的购物车
            if (shopCartInRedis.getSkuOutputDtoList().size()==0){
                redisTemplate.delete(Constants.SHOPCART_USER_KEY+":"+currentUser.getUuid().toString());
                return null;
            }
            redisTemplate.opsForHash().putAll(Constants.SHOPCART_USER_KEY+":"+currentUser.getUuid().toString(),shopCartInRedis.toMap());
            return shopCartInRedis;
        }
        return null;
    }
    /**
    *@Author: HouZeYu
    *@Description: 勾选购物车商品和取消勾选购物车商品
    *@Date: 14:26 2018/7/2
    */
    @Override
    public ShopCartOutputDto chooseShopcart(List<ProductSkuInputDto> skuInputDtoList, String ip, UserElement currentUser, HttpServletRequest request, HttpServletResponse response) throws UnsupportedEncodingException {
        //判断用户是否登录
        if (currentUser==null){
            //未登录则取出cookie中的购物车
        Cookie[] cookies= request.getCookies();
        for (int i=0; i<cookies.length;i++){
            if (cookies[i].getName().equals(ip)){
                String cookieCart=URLDecoder.decode(cookies[i].getValue(),"UTF-8");
                ShopCartOutputDto shopCartOutputDto= JSON.parseObject(cookieCart,new TypeReference<ShopCartOutputDto>() {} );
                skuInputDtoList.stream().forEach(param->{
                    ProductSkuOutputDto skuOutputDto=shopCartOutputDto.getSkuOutputDtoList().stream().filter(sku->sku.getId().equals(param.getSkuId())).findFirst().get();
                     //找到商品修改商品状态
                    skuOutputDto.setChooseSign(param.getChooseSign());
                    //修改购物车总价
                    if (param.getChooseSign().equals(SKU_NOTCHOOSE_STATUS)){
                        //取消选择则减去该商品总价
                        shopCartOutputDto.setTotalFavourablePrice(shopCartOutputDto.getTotalFavourablePrice().subtract((skuOutputDto.getSkuPrice().subtract(skuOutputDto.getActivityPrice())).multiply(new BigDecimal(skuOutputDto.getQuantity()))));
                        shopCartOutputDto.setTotalChooseSkuQuantity(shopCartOutputDto.getTotalChooseSkuQuantity()-skuOutputDto.getQuantity());
                        shopCartOutputDto.setShopCartTotalPrice(shopCartOutputDto.getShopCartTotalPrice().subtract(skuOutputDto.getTotalPrice()));
                    }else {
                        //勾选则加上该商品总价
                        shopCartOutputDto.setTotalFavourablePrice(shopCartOutputDto.getTotalFavourablePrice().add((skuOutputDto.getSkuPrice().subtract(skuOutputDto.getActivityPrice())).multiply(new BigDecimal(skuOutputDto.getQuantity()))));
                        shopCartOutputDto.setTotalChooseSkuQuantity(shopCartOutputDto.getTotalChooseSkuQuantity()+skuOutputDto.getQuantity());
                        shopCartOutputDto.setShopCartTotalPrice(shopCartOutputDto.getShopCartTotalPrice().add(skuOutputDto.getTotalPrice()));;
                    }
                });
                //修改完成存入cookie中
                String cart=JSON.toJSONString(shopCartOutputDto);
                Cookie cookie=new Cookie(ip,URLEncoder.encode(cart,"UTF-8"));
                response.addCookie(cookie);
                return shopCartOutputDto;
            }
        }
        }else {
            //用户已经登录则从redis中取出购物车
            Object object=redisTemplate.opsForHash().entries(Constants.SHOPCART_USER_KEY+":"+currentUser.getUuid().toString());
            Map<String,Object> map= (Map<String, Object>) object;
            //将map转化为shopcart类型
            ShopCartOutputDto shopCartInRedis= ShopCartOutputDto.fromMap(map);
            skuInputDtoList.stream().forEach(param->{
                ProductSkuOutputDto skuOutputDto=shopCartInRedis.getSkuOutputDtoList().stream().filter(sku->sku.getId().equals(param.getSkuId())).findFirst().get();
                    skuOutputDto.setChooseSign(param.getChooseSign());
                if (param.getChooseSign().equals(SKU_NOTCHOOSE_STATUS)){
                    //取消选择则减去该商品总价
                    shopCartInRedis.setTotalFavourablePrice(shopCartInRedis.getTotalFavourablePrice().subtract((skuOutputDto.getSkuPrice().subtract(skuOutputDto.getActivityPrice())).multiply(new BigDecimal(skuOutputDto.getQuantity()))));
                    shopCartInRedis.setTotalChooseSkuQuantity(shopCartInRedis.getTotalChooseSkuQuantity()-skuOutputDto.getQuantity());
                    shopCartInRedis.setShopCartTotalPrice(shopCartInRedis.getShopCartTotalPrice().subtract(skuOutputDto.getTotalPrice()));
                }else {
                    //勾选则加上该商品总价
                    shopCartInRedis.setTotalFavourablePrice(shopCartInRedis.getTotalFavourablePrice().add((skuOutputDto.getSkuPrice().subtract(skuOutputDto.getActivityPrice())).multiply(new BigDecimal(skuOutputDto.getQuantity()))));
                    shopCartInRedis.setTotalChooseSkuQuantity(shopCartInRedis.getTotalChooseSkuQuantity()+skuOutputDto.getQuantity());
                    shopCartInRedis.setShopCartTotalPrice(shopCartInRedis.getShopCartTotalPrice().add(skuOutputDto.getTotalPrice()));;
                }
            });
            //存入redis删除后的购物车
            redisTemplate.opsForHash().putAll(Constants.SHOPCART_USER_KEY+":"+currentUser.getUuid().toString(),shopCartInRedis.toMap());
            return shopCartInRedis;
        }
        return null;
    }

    /**
    *@Author: HouZeYu
    *@Description: 创建存入redis和cookie的购物车实例
    *@Date: 10:12 2018/6/13
    */
    private ShopCartOutputDto addNewShopCart(List<ProductSkuInputDto> skuInputDtoList) {
        final Integer[] totalQuantity = {0};
        final BigDecimal[] totalPrice = {BigDecimal.ZERO,BigDecimal.ZERO};
        ShopCartOutputDto shopCartOutputDto=new ShopCartOutputDto();

        //拼装查询的skuIdSet
        Set<Long> longs=new HashSet<>();
        skuInputDtoList.stream().forEach(param->{
            longs.add(param.getSkuId());
        });
        //调用商品服务查询对应id的商品信息
        List<ProductSku> skuList= goodsServiceClient.selectGoodsBySkuId(longs).getData();
        List<ProductSkuOutputDto> skuOutputDtoList=new ArrayList<>();
        //拼装购物车信息
        skuList.stream().forEach(param->{
            ProductSkuInputDto skuInputDto=skuInputDtoList.stream().filter(sku->sku.getSkuId()==param.getId()).findFirst().get();
             //调用计价服务查询该商品应付价格
            BigDecimal prcie=valuationGoodsPrice.valuationGoodsPrice(param);
            ProductSkuOutputDto outputDto=new ProductSkuOutputDto();
            outputDto.setId(param.getId());
            outputDto.setImgUrl(param.getImgUrl());
            outputDto.setChooseSign(SKU_CHOOSE_STATUS);
            outputDto.setSkuPrice(param.getSkuPrice());
            outputDto.setActivityPrice(prcie);
            outputDto.setQuantity(skuInputDto.getQuantity());
            BigDecimal total=prcie.multiply(new BigDecimal(skuInputDto.getQuantity()));
            outputDto.setTotalPrice(total);
            totalQuantity[0] +=skuInputDto.getQuantity();
            totalPrice[0]=totalPrice[0].add(total);
            totalPrice[1]=totalPrice[1].add(outputDto.getSkuPrice().multiply(new BigDecimal(skuInputDto.getQuantity())).subtract(outputDto.getTotalPrice()));
            skuOutputDtoList.add(outputDto);
        });
        shopCartOutputDto.setTotalFavourablePrice(totalPrice[1]);
        shopCartOutputDto.setTotalChooseSkuQuantity(totalQuantity[0]);
        shopCartOutputDto.setShopCartTotalPrice(totalPrice[0]);
        shopCartOutputDto.setSkuOutputDtoList(skuOutputDtoList);
         return shopCartOutputDto;
    }
}
